//
// Created by lenovo on 2023/12/24.
//
#include<bits/stdc++.h>
using namespace std;
int high[302];

int main()
{
    int n = 0;
    cin >> n;
    for(int i = 1;i <= n;i++){
        cin >> high[i];
    }
    sort(high + 1, high + n + 1);
    int l = 0, r = n;
    long long ans = 0;
    while(l < r)
    {
        ans += pow(high[r] - high[l] , 2);
        l++;
        ans += pow(high[l] - high[r], 2);
        r--;
    }
    cout << ans;
    return 0;
}